@extends('admin.index.layout')

@section('title', $title)

@section('content')
    
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                商品管理
                <small>商品修改</small>
            </h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i> 主页</a></li>
                <li><a href="#">商品管理</a></li>
                <li class="active">商品编辑</li>
            </ol>
        </section>

        <!-- Main content -->
        <section class="content">
            <div class="row">
                <!-- left column -->
                <div class="col-md-12">
                    <!-- general form elements -->
                    <div class="box box-primary">
                        <div class="box-header with-border">
                            <h3 class="box-title">快速编辑</h3>
                        </div><!-- /.box-header -->
                        <!-- form start -->
                        <form role="form" action="{{url('/admin/shop/update')}}/{{$id}}" method="post" enctype="multipart/form-data">
                            <div class="box-body">
                            
                            {{ csrf_field() }}
                                <div class="row">
                                    <div class="form-group col-md-3">
                                        <label>商品分类</label>
                                        <select name="type_id" class="form-control">
                                            @foreach($gclass as $u)
                                            <option value="{{ $u -> id }}">{{$u -> tname }}</option>

                                            @endforeach
                                        </select>       
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="form-group col-md-3">
                                        <label for="exampleInputName">编辑商品名</label>
                                        <input name="gname" value="{{ $data[0] -> gname}}" type="text" class="form-control" id="exampleInputName"
                                               placeholder="商品名">
                                    </div>
                                </div>
                                <div class="row">
                                <div class="form-group col-md-2">
                                        <div class="form-group">
                                            <label>售价:</label>
                                            <div class="input-group">
                                                <input name="gprice" value="{{ $data[0] -> gprice}}" class="form-control" type="text">
                                                <div class="input-group-addon">
                                                    <i class="fa  fa-rmb "></i>
                                                </div>
                                            </div><!-- /.input group -->
                                        </div>     
                                </div><!-- /.input group -->
                                <div class="form-group col-md-2">
                                        <div class="form-group">
                                            <label>进价:</label>
                                            <div class="input-group">
                                                <input name="price" value="{{ $stock[0] -> price}}" class="form-control" type="text">
                                                <div class="input-group-addon">
                                                    <i class="fa  fa-rmb "></i>
                                                </div>
                                            </div><!-- /.input group -->
                                        </div>     
                                </div><!-- /.input group -->
                                </div>
                                <div class="row">
                                     <div class="form-group col-md-2">
                                        <div class="form-group">
                                            <label>商品总量:</label>
                                            <div class="input-group">
                                                <input name="total" value="{{ $stock[0] -> total}}" class="form-control" type="text">
                                            <div class="input-group-addon">
                                                <i class="fa fa-pie-chart "></i>
                                            </div>
                                        </div><!-- /.input group -->
                                    </div>     
                                </div><!-- /.input group -->   
                                </div>
                                <div class="row">
                                    <div class="col-xs-2">
                                        <div class="form-group">
                                            <label>省市</label>
                                            <select name="city" id='p' style="width: 100%;" class="form-control select2 select2-hidden-accessible" tabindex="-1" aria-hidden="true">
                                              
                                            </select>
                                        </div>
                                    </div>
                                    <div class="col-xs-4">
                                        <div class="form-group">
                                            <label>区县</label>
                                            <select name="qx" id='c' style="width: 100%;" class="form-control select2 select2-hidden-accessible" tabindex="-1" aria-hidden="true">
                                                
                                            </select>
                                        </div>
                                    </div>
                                    <div class="col-xs-5">
                                        <div class="form-group">
                                            <label>具体产地</label>
                                            <div class="input-group">
                                                <input name="xqhome" value="{{ $data[0] -> home}}"  class="form-control" type="text">
                                                <div class="input-group-addon">
                                                    <i class="fa  fa-home "></i>
                                                </div>
                                            </div><!-- /.input group -->
                                        </div>
                                    </div>
                                </div>
                            </div><!-- /.box-body -->

                            <div class="box-footer">
                                <button type="submit" class="btn btn-primary">提交</button>
                                <button type="reset" class="btn btn-default">重置</button>
                            </div>

                        </div>   
                      </form>
                    </div><!-- /.box -->

                  

              

                

                </div><!--/.col (left) -->
                <!-- right column -->
     </div>
        </div>
        </div>

     </div>

        </div>
        </div>
     <script type="text/javascript">
        window.onload = function()
        {
            
            setInterval(function(){
                $('#jg').fadeOut();
                
            }, 2000);

        var p = document.getElementById('p');
        var c = document.getElementById('c');
        // console.log(city[1].text);
        var pstr = '';
        for (var i = 0; i < city.length ; i++) {
            // console.log(city[i].text);
             pstr += "<option value='" + i + "'>" + city[i].text +"</option>";
        };

        p.innerHTML = pstr;

        var pval = p.value;

        var mstr = '';
        for (var j = 0; j < city[pval].children.length; j++) {
            // console.log(city[pval].children[j].text);
            mstr += "<option name='sheng' value='" + j + "'>" + city[pval].children[j].text +"</option>";
        };

        c.innerHTML = mstr;

        p.onchange = function(){
            var val = this.value;


            var cstr = '';


            for(var j = 0; j < city[val].children.length; j ++){
                cstr += "<option name='sheng' value='" + j + "'>" + city[val].children[j].text + "</option>";
            }


            c.innerHTML = cstr;
        }


        }

     </script>

@endsection